
<div class="row">
  <div class="col-xs-12 col-md-12">
    <div class="widget">
      <div class="widget-header ">
        <span class="widget-caption">功能列表</span>
        <div class="widget-buttons">
          <a href="#" data-toggle="maximize">
            <i class="fa fa-expand"></i>
          </a>
          <a href="#" data-toggle="collapse">
            <i class="fa fa-minus"></i>
          </a>
          <a href="#" data-toggle="dispose">
            <i class="fa fa-times"></i>
          </a>
        </div>
      </div>
      <div class="widget-body">
        <div class="table-toolbar">
          <a  href="Module/new" class="btn btn-default">创建功能</a>
        </div>
        <div role="grid" id="editabledatatable_wrapper" class="dataTables_wrapper form-inline no-footer">
          <table class="table table-striped table-hover table-bordered dataTable no-footer" id="editabledatatable" aria-describedby="editabledatatable_info">
            <thead>
            <tr role="row">
              <th rowspan="1" colspan="1" style="min-width: 120px;">名称</th>
              <th rowspan="1" colspan="1" style="min-width: 80px;">导航</th>
              <th rowspan="1" colspan="1" style="min-width: 80px;">描述</th>
              <th rowspan="1" colspan="1" style="min-width: 80px;">Tag</th>
              <th class="sorting_disabled" rowspan="1" colspan="1" style="min-width: 70px;">排序</th>
              <th rowspan="1" colspan="1" aria-label="" style="min-width: 70px;"></th>
            </tr>
            </thead>
            <tbody id='tbContent'>

            </tbody>
          </table>
          <div class="row DTTTFooter">
            <div class="col-sm-6">
              <div class="dataTables_info" id="editabledatatable_info" role="alert" aria-live="polite" aria-relevant="all">Showing 1 to 5 of 6 entries
              </div>
            </div>
            <div class="col-sm-6">
              <div class="dataTables_paginate paging_bootstrap" id="editabledatatable_paginate">
                <ul class="pagination">
                  <li class="prev disabled"><a href="#">Prev</a></li>
                  <li class="active"><a href="#">1</a></li>
                  <li><a href="#">2</a></li>
                  <li class="next"><a href="#">Next</a></li>
                </ul>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
  function createRow(m,row,lv){
    lv=lv ||0;
    var str="<tr id='row"+m.id+"'><td>";
    //str+="<span class='shiny icon-only glyphicon glyphicon-"+m.icon+"' />";
    if(lv>0){
      str+="|";
    }
    for(var i=0;i<lv;i++){
      str+="-----";
    }
    str+=m.name;

    str+="<span class='pull-right shiny icon-only glyphicon glyphicon-"+m.icon+"' />"+"</td>";

    str+="<td>"+(m.showInNav?'是':'否')+"</td>\
      <td>"+m.desc+"</td>\
      <td>"+m.tag+"</td>\
      <td>"+m.sort||0+"</td>";
    str+="<td><a class='btn btn-info btn-xs edit' ";
    if (m.tag==='SYS_MANAGE') {
      str+="disabled='disabled'";
    }
    str+= " href='/Module/edit/"+m.id+"' >修改</a>";
    str+="&nbsp;<a class='btn btn-danger btn-xs delete' ";
    if (m.tag==='SYS_MANAGE') {
      str+="disabled='disabled'";
    }
    str+= " href='#' onclick='funDel('"+m.id+"');'>删除</a>";
    str+="</td></tr>";
    if(row){
      row.after(str);
    }
    else{
      $("#tbContent").append(str);
    }

    $.get('/Module/getChildModule/'+m.id,function(modules){
      modules.forEach(function(cm){
        createRow(cm,$("#row"+m.id),lv+1);
      });
    });
  }
  $().ready(function(){
    $.get('/Module/getChildModule/0',function(modules){
      modules.forEach(function(m){
        createRow(m);
      });
    });
  });
</script>
